package sk.fiit.lulco.grafy;

import java.util.Collections;

public class TabuColoringAlgorithm extends AbstractAlgorithm {
	
	private static final VertexBrelazComparator comparator = new VertexBrelazComparator(HEALConstants.SortType.DESC);
	
	public Graph color(Graph graph) {
		while (!graph.isColored()) {
			Collections.sort(graph.getVertices(), comparator);
			Vertex vertex = graph.getVertices().get(0);
			int minimalColor;
			minimalColor = graph.getMinimalFreeColor(vertex.getNeighbours(), vertex.getPreviousColors());
			vertex.setColor(minimalColor);
		}
		return graph;
	}
}
